這天再來划水,因為是各個專案遊走而不是主力開發,不熟正規方式從DB來生成Value Object,那鑽木取火臨時建個VO來測也行。
例:從Oracle Developer下SQL指令desc TBSYSFTP得
名稱 空值? 類型
-------------- -------- -------------
FTPSETTINGID NOT NULL VARCHAR2(20)
SRCDIRECTORY VARCHAR2(200)
SRCFILENAME VARCHAR2(100)
CHECKFILE VARCHAR2(100)
DESDIRECTORY VARCHAR2(200)
DESFILENAME VARCHAR2(100)
REPEAT NUMBER
REPEATINTERVAL NUMBER
HOSTID VARCHAR2(20)
SRCDELETE VARCHAR2(2)
REMARK VARCHAR2(100)
VERSION NOT NULL NUMBER
CREATOR VARCHAR2(20)
CREATETIME DATE
MODIFIER VARCHAR2(20)
LASTUPDATE DATE
複製第三行起以下所有內容貼到Sublime用Regex進行替換(其它文字編輯器除非太陽春,大部份都有支援Regex):
(.+?) .+
\t@Column(name = "\1")\n\tprivate String \1;\n
得到結果如下,非字串欄位再自行修改:
@Column(name = "FTPSETTINGID")
private String FTPSETTINGID;
@Column(name = "SRCDIRECTORY")
private String SRCDIRECTORY;
@Column(name = "SRCFILENAME")
private String SRCFILENAME;
@Column(name = "CHECKFILE")
private String CHECKFILE;
@Column(name = "DESDIRECTORY")
private String DESDIRECTORY;
@Column(name = "DESFILENAME")
private String DESFILENAME;
@Column(name = "REPEAT")
private String REPEAT;
@Column(name = "REPEATINTERVAL")
private String REPEATINTERVAL;
@Column(name = "HOSTID")
private String HOSTID;
@Column(name = "SRCDELETE")
private String SRCDELETE;
@Column(name = "REMARK")
private String REMARK;
@Column(name = "VERSION")
private String VERSION;
@Column(name = "CREATOR")
private String CREATOR;